<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    .red {
      color: red;
    }
    .big {
      font-size: 30px;
    }
    .st {
      font-weight: 900;
    }
  </style>
</head>
<body>
  <div id="app">
    <h1>class的绑定</h1>
    <!-- 拼接字符串 -->
    <!-- <p :class="className">hello Vue!</p> -->
    <!-- 用布尔值来控制 -->
    <!-- <p :class="isRed ? 'red' : ''">hello Vue!</p> -->


    <!-- vue对class做了特殊增强，允许我们使用对象 或者 数组(数组不需要掌握) -->
    <!-- 对象的key表示的是类名，value表示的是布尔值，用于控制是否要加前面的类名 -->
    <!-- 还允许class和:class一起使用 -->
    <p :class="{ red: isRed, big: big === 1 }" class="st">hello Vue!</p>
    <button v-on:click="changeColor">change color</button>



    <div :class="{ red: done === 1 }" v-on:click="done = 1">123</div>
    <div :class="{ red: done === 2 }" v-on:click="done = 2">456</div>
    <div :class="{ red: done === 3 }" v-on:click="done = 3">789</div>
  </div>

  <script src="../Vue.js"></script>

  <script>
    const { createApp } = Vue;

    createApp({
      data() {
        return {
          // className: "red"
          isRed: true,
          big: 2,
          done: 1
        }
      },
      methods: {
        changeColor() {
          // this.className = this.className === "red" ? "" : "red";
          this.isRed = !this.isRed
        }
      }
    }).mount("#app")

  </script>
</body>
</html>